using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class diary_drug_historyMap : EntityTypeConfiguration<diary_drug_history>
    {
        public diary_drug_historyMap()
        {
            // Primary Key
            this.HasKey(t => t.diary_drug_history_id);

            // Properties
            this.Property(t => t.drug_name)
                .HasMaxLength(100);

            this.Property(t => t.dosage_unit)
                .HasMaxLength(20);

            this.Property(t => t.usage)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("diary_drug_history");
            this.Property(t => t.diary_drug_history_id).HasColumnName("diary_drug_history_id");
            this.Property(t => t.diary_id).HasColumnName("diary_id");
            this.Property(t => t.drug_name).HasColumnName("drug_name");
            this.Property(t => t.dosage).HasColumnName("dosage");
            this.Property(t => t.frequency).HasColumnName("frequency");
            this.Property(t => t.dosage_unit).HasColumnName("dosage_unit");
            this.Property(t => t.usage).HasColumnName("usage");

            // Relationships
            this.HasOptional(t => t.patient_diary)
                .WithMany(t => t.diary_drug_history)
                .HasForeignKey(d => d.diary_id);

        }
    }
}
